<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link rel="stylesheet" href="../css/index.css">
    <script src="https://cdn.bootcss.com/jquery/3.4.1/jquery.js"></script>
</head>
<body>
    <div class="container">
        <div class="item">吴樟我儿子</div>
        <div class="item">吴樟傻逼</div>
        <div class="item">吴樟大傻逼</div>
        <div class="item">吴樟个掉毛</div>
        <div class="item">谢谢惠顾</div>
        <div class="item">一等奖</div>
        <div class="item">二等奖</div>
        <div class="item">谢谢惠顾</div>
        <div class="item">三等奖</div>
    </div>
    <button id="btn">开始</button>
    <script>
        var div = document.getElementsByClassName("item")
        var timer
        $("#btn").click(function(){
            var arr = []
            var current = 0
            for(var i=0;i<9;i++){
                arr.push(Math.floor(Math.random()*9))
            }
            console.log(arr);
            timer = setInterval(()=>{
                if(current==8){
                    clearInterval(timer)
                }
                $(div).eq(arr[current]).addClass("active")
                .siblings().removeClass("active")
                console.log(arr[current]);
                current++
            },500)
        })
    </script>
</body>
</html>